package com.irs.irsforum.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * <p>
 * 
 * </p>
 *
 * @author yihuili
 * @since 2020-01-18
 */
@Data
@TableName("forum_comment")
public class Comment extends Model<Comment> {

    private static final long serialVersionUID = 1L;

	@TableId(value="id", type= IdType.AUTO)
	private Long id;
	@TableField("post_id")
	private Long postId;
	@TableField("user_id")
	private Long userId;
	@TableField("content")
	private String content;
	@TableField("creationTime")
	private Timestamp creationTime;
	@TableField("reply")
	private String reply;
	/** 0：不存在 1:存在*/
	@TableField("comment_type")
	private Integer commentType;

	private String userNickName;

	/**1: 发送者 0;非发送者*/
	private Integer isSender = 0;

	public Comment(Long id, Integer commentType) {
		this.id = id;
		this.commentType = commentType;
	}

	public Comment(Long id, Long userId, Integer commentType) {
		this.id = id;
		this.userId = userId;
		this.commentType = commentType;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	public Timestamp getCreationTime() {
		return creationTime;
	}

	@Override
	protected Serializable pkVal() {
		return this.id;
	}

	@Override
	public String toString() {
		return "Comment{" +
				"id=" + id +
				", postId=" + postId +
				", userId=" + userId +
				", content='" + content + '\'' +
				", creationTime=" + creationTime +
				", reply='" + reply + '\'' +
				", commentType=" + commentType +
				", userNickName='" + userNickName + '\'' +
				", isSender=" + isSender +
				'}';
	}
}
